<template>
	<view>
		
		<view class="container">
			<view class="notice_list">
				<view class="notice_item" v-for="item,id in list" :key="id" @tap="go_detail(item.id)">
					<view class="" style="padding-top: 0rpx;">
						<n-icon name="notificationfill" size="32" color="#DEBC86"></n-icon>
					</view>
					<view class="notice_info">
						{{item.title}}
						<view class="c_time">
							发布时间：
							{{item.ctime}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
	</view>
</template>
<style>
	.c_time {
		font-size: 24rpx;
		color: #b9b9b9;
		padding-top: 10rpx;
		width: 100%;
	}

	.notice_info {
		color: #fff;
		font-size: 28rpx;
		padding-left: 10rpx;

	}

	.notice_item {
		width: 100%;
		padding: 26rpx 20rpx;
		display: flex;
		margin-bottom: 30rpx;
		background: #292B2B;
		border-radius: 20rpx;

	}

	.notice_list {
		width: 100%;
		padding: 50rpx 0rpx;
		position: relative;

	}

	.container {
		width: 100%;
		padding: 0 45rpx;
	}

	page {}
</style>
<script>
	export default {
		data() {
			return {
				page: 1,
				limit: 20,
				hasNextPage: true,
				list: [],

				type_list: [],
				current: 0
			}
		},
		onReachBottom() {
			if (this.hasNextPage) {

				let new_page = this.page + 1;
				let data = {
					page: new_page,
					limit: this.limit
				}
				data.token = this.$db.get('userToken')
				this.$api.notice(data, res => {
					this.list = this.list.concat(res.data);
					this.hasNextPage = res.data.length >= this.limit;
					this.page = new_page;
				})

			}
		},
		methods: {
			on_tab_click: function(e) {
				console.log(e)
				this.current = e;

				this.get_data_list()
			},


			go_detail: function(id) {
				this.$common.navigateTo('/pages/article/index?id=' + id + '&id_type=2')
			},

			get_data_list: function() {
				this.page = 1;
				this.hasNextPage = true
				this.list = [];
				let t = {
					page: this.page,
					limit: this.limit
				}

				if (this.current != 0) {
					t.type = this.type_list[this.current].id
				}
				t.token = this.$db.get('userToken')

				this.$api.notice(t, res => {
					this.list = res.data
					this.hasNextPage = res.data.length >= this.limit;
				})
			}
		},
		onLoad() {
			let data = {}
			this.$api.noticeType(data, res => {
				if (res.status) {
					this.type_list = res.data
				}
			})
			this.get_data_list()
		}
	}
</script>

<style>

</style>
